# 图像处理
import cv2
#
# # 读图
# img = cv2.imread('./code.png', cv2.IMREAD_GRAYSCALE)
# print(img)
#
# # 写图
# cv2.imwrite('./code1.png', img)


# from PIL import Image, ImageDraw
#
# # 读图
# im = Image.open('./static/upload/海边清纯美女帽子白色.jpg')
#
# print(im.format, im.size, im.mode)
#
# # 生成画笔
# draw = ImageDraw.Draw(im)
#
# # 绘制
# draw.text((0, 0), 'fjk', fill=(76, 234, 124, 180))
#
# im.show()


# 图像压缩
# 读图
img = cv2.imread('./static/sina.png')
# 压缩操作 0-9  等级越高像素越差
cv2.imwrite('./static/upload/1.png', img, [cv2.IMWRITE_PNG_COMPRESSION, 5])

# jpg压缩
# cv2.imwrite('./static/upload/1.jpg', img, [cv2.IMWRITE_JPEG_QUALITY, 5])
